fluent-bit:
  # kind -- DaemonSet or Deployment
  kind: DaemonSet

  image:
    repository: cr.fluentbit.io/fluent/fluent-bit
    # Overrides the image tag whose default is {{ .Chart.AppVersion }}
    tag: "1.9.5"
    pullPolicy: IfNotPresent

  testFramework:
    image:
      repository: busybox
      pullPolicy: IfNotPresent
      tag: latest

  nameOverride: "fluentbit"
  fullnameOverride: "fluentbit"

  serviceAccount:
    create: true

  rbac:
    create: true
    nodeAccess: false

  podSecurityPolicy:
    create: false
    annotations: {}

  openShift:
    enabled: false

  podSecurityContext: {}
  #   fsGroup: 2000

  hostNetwork: false
  dnsPolicy: ClusterFirst

  securityContext: {}
  #   capabilities:
  #     drop:
  #     - ALL
  #   readOnlyRootFilesystem: true
  #   runAsNonRoot: true
  #   runAsUser: 1000

  service:
    type: ClusterIP
    port: 2020
    labels: {}
    # nodePort: 30020
    # clusterIP: 172.16.10.1
    annotations: {}
  #   prometheus.io/path: "/api/v1/metrics/prometheus"
  #   prometheus.io/port: "2020"
  #   prometheus.io/scrape: "true"

  serviceMonitor:
    enabled: false
  #   namespace: monitoring
  #   interval: 10s
  #   scrapeTimeout: 10s
  #   jobLabel: fluentbit
  #   selector:
  #    prometheus: my-prometheus
  #  ## metric relabel configs to apply to samples before ingestion.
  #  ##
  #  metricRelabelings:
  #    - sourceLabels: [__meta_kubernetes_service_label_cluster]
  #      targetLabel: cluster
  #      regex: (.*)
  #      replacement: ${1}
  #      action: replace
  #  ## relabel configs to apply to samples after ingestion.
  #  ##
  #  relabelings:
  #    - sourceLabels: [__meta_kubernetes_pod_node_name]
  #      separator: ;
  #      regex: ^(.*)$
  #      targetLabel: nodename
  #      replacement: $1
  #      action: replace

  prometheusRule:
    enabled: false
  #   namespace: ""
  #   additionalLabels: {}
  #   rules:
  #   - alert: NoOutputBytesProcessed
  #     expr: rate(fluentbit_output_proc_bytes_total[5m]) == 0
  #     annotations:
  #       message: |
  #         Fluent Bit instance {{ $labels.instance }}'s output plugin {{ $labels.name }} has not processed any
  #         bytes for at least 15 minutes.
  #       summary: No Output Bytes Processed
  #     for: 15m
  #     labels:
  #       severity: critical

  dashboards:
    enabled: false
    labelKey: grafana_dashboard
    annotations: {}
    namespace: ""

  lifecycle: {}
    # preStop:
    #   exec:
    #     command: ["/bin/sh", "-c", "sleep 20"]

  livenessProbe:
    httpGet:
      path: /
      port: http

  readinessProbe:
    httpGet:
      path: /api/v1/health
      port: http

  resources:
    limits:
      cpu: 500m
      memory: 256Mi
    requests:
      cpu: 100m
      memory: 128Mi

  ## only available if kind is Deployment
  ingress:
    enabled: false

  ## only available if kind is Deployment
  autoscaling:
    enabled: false

  ## only available if kind is Deployment
  podDisruptionBudget:
    enabled: false

  tolerations:
    - key: node-role.kubernetes.io/master
      operator: Exists
      effect: NoSchedule
    - operator: "Exists"
      effect: "NoExecute"
    - operator: "Exists"
      effect: "NoSchedule"


  env:
    - name: PLATFORM
      value: "testing"

  flush: 1
  metricsPort: 2020
  # Make use of a pre-defined configmap instead of the one templated here
  existingConfigMap: ""

  networkPolicy:
    enabled: false
  #   ingress:
  #     from: []

  luaScripts: {}

  ## https://docs.fluentbit.io/manual/administration/configuring-fluent-bit/configuration-file
  config:
    service: |
      [SERVICE]
          Daemon Off
          Flush {{ .Values.flush }}
          Log_Level {{ .Values.logLevel }}
          Parsers_File parsers.conf
          Parsers_File custom_parsers.conf
          HTTP_Server On
          HTTP_Listen 0.0.0.0
          HTTP_Port {{ .Values.metricsPort }}
          Health_Check On

    ## https://docs.fluentbit.io/manual/pipeline/inputs
    inputs: |
      [INPUT]
          Name tail
          Path /var/log/containers/*.log
          multiline.parser docker, cri
          Tag kube.*
          Mem_Buf_Limit 5MB
          Skip_Long_Lines On
      [INPUT]
          Name tail
          Tag host.log.mail
          Parser sys_log_file
          Path /var/log/mail
          db /var/log/_mail_.db
      [INPUT]
          Name tail
          Tag host.log.secure
          Parser sys_log_file
          Path /var/log/secure
          db /var/log/_secure_.db
      [INPUT]
          Name tail
          Tag host.log.messages
          Parser sys_log_file
          Path /var/log/messages
          db /var/log/_messages_.db
      [INPUT]
          Name tail
          Tag host.log.cron
          Parser sys_log_file
          Path /var/log/cron
          db /var/log/_cron_.db

    ## https://docs.fluentbit.io/manual/pipeline/filters
    filters: |
      [FILTER]
          Name kubernetes
          Match kube.*
          Merge_Log On
          Keep_Log Off
          K8S-Logging.Parser On
          K8S-Logging.Exclude On
      [FILTER]
          Name modify
          Match host.log.mail
          Set app syslog
          Set file /var/log/mail
      [FILTER]
          Name modify
          Match host.log.secure
          Set app syslog
          Set file /var/log/secure
      [FILTER]
          Name modify
          Match host.log.messages
          Set app syslog
          Set file /var/log/messages
      [FILTER]
          Name modify
          Match host.log.cron
          Set app syslog
          Set file /var/log/cron

    ## https://docs.fluentbit.io/manual/pipeline/outputs
    outputs: |
      [OUTPUT]
          Name        kafka
          Match       kube.*
          Brokers     kafka.kafka.svc:9092
          Topics      kube
  
      [OUTPUT]
          Name        kafka
          Match       host.log.*
          Brokers     kafka.kafka.svc:9092
          Topics      host


    ## https://docs.fluentbit.io/manual/pipeline/parsers
    customParsers: |
      [PARSER]
          Name docker_no_time
          Format json
          Time_Keep Off
          Time_Key time
          Time_Format %Y-%m-%dT%H:%M:%S.%L
      [PARSER]
          Format regex
          Name sys_log_file
          Regex (?<message>(?<time>[^ ]*\s{1,2}[^ ]*\s[^ ]*)\s(?<host>[a-zA-Z0-9_\/\.\-]*)\s.*)$
          Time_Format %b %d %H:%M:%S
          Time_Keep Off
          Time_Key time
          Time_Offset +0300

    # This allows adding more files with arbitary filenames to /fluent-bit/etc by providing key/value pairs.
    # The key becomes the filename, the value becomes the file content.
    extraFiles: {}
  #     example.conf: |
  #       [OUTPUT]
  #           Name example
  #           Match foo.*
  #           Host bar

  # The config volume is mounted by default, either to the existingConfigMap value, or the default of "fluent-bit.fullname"
  volumeMounts:
    - name: config
      mountPath: /fluent-bit/etc/fluent-bit.conf
      subPath: fluent-bit.conf
    - name: config
      mountPath: /fluent-bit/etc/custom_parsers.conf
      subPath: custom_parsers.conf

  daemonSetVolumes:
    - name: varlog
      hostPath:
        path: /var/log
    - name: varlibdockercontainers
      hostPath:
        path: /var/lib/docker/containers
    - name: etcmachineid
      hostPath:
        path: /etc/machine-id
        type: File

  daemonSetVolumeMounts:
    - name: varlog
      mountPath: /var/log
    - name: varlibdockercontainers
      mountPath: /var/lib/docker/containers
      readOnly: true
    - name: etcmachineid
      mountPath: /etc/machine-id
      readOnly: true

  logLevel: info
